/**
 * @param {number[]} array
 * @return {number[]}
 */

//  [1,2,4,7,10,11,7,12,6,7,16,18,19]
var subSort = function (array) {
  let left = -1, right = -1
  let max = Number.MIN_SAFE_INTEGER
  let min = Number.MAX_SAFE_INTEGER
  for (let i = 0; i < array.length; i++) {
    if (array[i] >= max) {
      max = array[i]
    } else {
      right = i
    }
  }

  for (let i = array.length - 1; i >= 0; i--) {
    if (array[i] <= min) {
      min = array[i]
    } else {
      left = i
    }
  }

  return [left, right]
};